﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Windows.Media;

namespace SnakeGame.Helpers
{
    public class MyMediaPlayer : MediaPlayer
    {
        public bool IsRepeating { get; set;}
        
        public bool IsMusicPlaying
        {
            get; set;
        }

        public MyMediaPlayer()
        {
            base.MediaEnded += new EventHandler(SoundPlayer_MediaEnded);
        }

        private void SoundPlayer_MediaEnded(object sender, EventArgs e)
        {
            if (IsRepeating)
                this.Position = new TimeSpan(0); //Rewind the position
        }

        public void ToggleMusic()
        {
            if (IsMusicPlaying)
            {
                this.Pause();
                IsMusicPlaying = false;
            }
            else
            {
               this.Play();
               IsMusicPlaying = true;
            }
        }


    }
}
